Dynomotion

Group: DynoMotion Message: 8921 From: tapiolarikka Date: 1/23/2014
Subject: MyCustom.c on thread 5?
Hi Tom!

How do I download and a c program on another thread from MachNotifyPlugin?

Rgds,
Tapio
Group: DynoMotion Message: 8923 From: Tom Kerekes Date: 1/23/2014
Subject: Re: MyCustom.c on thread 5?
Hi Tapio,

The Mach3 Reset, Notify, and Spindle programs can run in different threads.  There isn't an easy way to run additional things in other threads.  What are you trying to do?

Regards
TK


Group: DynoMotion Message: 8926 From: Tapio Larikka Date: 1/23/2014
Subject: Re: MyCustom.c on thread 5?

Hi Tom,
 
I want to control my work piece loader.  It's a simple setup with pneumatic cylinders and inductive sensors so it's basicly setting and reading bits
and a few while statements, but it needs to run concurrently with the g-code execution.
 
I figured this could be with either a MachNotify "if(message==10900) then execute MyCustom.c on thread 5"
or with a "if (readBit) then execute MyCustom.c on thread 5" in init.c forever loop.
 
I tried to find syntax/code example on launching a c-program in a new thread but didn't find any.
 
I'd also like this routine to download the c program every time it gets executed, so that I can rewrite the c program from mach script when needed.
 
Rgds,
Tapio
 
 
 
----- Original Message -----
Sent: Thursday, January 23, 2014 10:02 PM
Subject: Re: [DynoMotion] MyCustom.c on thread 5?

 

Hi Tapio,

The Mach3 Reset, Notify, and Spindle programs can run in different threads.  There isn't an easy way to run additional things in other threads.  What are you trying to do?

Regards
TK


Group: DynoMotion Message: 8928 From: Tom Kerekes Date: 1/23/2014
Subject: Re: MyCustom.c on thread 5?
Hi Tapio,

We don't currently have a mechanism for having KFLOP request the PC to compile/download/execute a file to a specified Thread.  We haven't encountered a case yet where it is necessary.

I'm not sure what you mean by "concurrently".  Wouldn't the GCode need to pause while the workpiece is being loaded?

The normal way to do this would be to add your sequence to the Notify.c program.  You could put the code in a separate file and #include it into the Notify.c program so that it could easily modified by something.

Regards
TK


Group: DynoMotion Message: 8930 From: Tapio Larikka Date: 1/23/2014
Subject: Re: MyCustom.c on thread 5?

Hi Tom,
 
If I put the sequence in Notify.c would that not block the notify from other notify messages while executing?
 
G-code part program starts by getting the workpiece, and while the piece is machined the loader will get the next one from magazine.
 
Rgds,
Tapio
 
 
----- Original Message -----
Sent: Thursday, January 23, 2014 11:15 PM
Subject: Re: [DynoMotion] MyCustom.c on thread 5?

 

Hi Tapio,

We don't currently have a mechanism for having KFLOP request the PC to compile/download/execute a file to a specified Thread.  We haven't encountered a case yet where it is necessary.

I'm not sure what you mean by "concurrently".  Wouldn't the GCode need to pause while the workpiece is being loaded?

The normal way to do this would be to add your sequence to the Notify.c program.  You could put the code in a separate file and #include it into the Notify.c program so that it could easily modified by something.

Regards
TK


Group: DynoMotion Message: 8936 From: Tom Kerekes Date: 1/23/2014
Subject: Re: MyCustom.c on thread 5?
Hi Tapio,

ok now I understand the issue better.

Yes one request to execute Notify.c will block a subsequent request to execute Notify.c for something else (the requests are actually queued by our Plugin).  It will not necessarily block GCode from executing. 

So for example the Load Workpiece Sequence could be launched and G code could continue milling concurrently unless the Gcode came to a point where it need to do another Notify.c operation (like a tool change).  Then there would be a problem.  But Spindle commands, IO Bits, or DRO uploads/downloads would not be a problem.

The other solution for true concurrent operation would be similar to what you mentioned of using the Init.c program and a forever loop.  It could monitor a virtual I/O bit or Variable as a "go" command.  But then instead of launcing a new Thread as you proposed it could just perform the sequence.  Since the Init program is only compiled/downloaded/executed every time Mach3 RESET is pushed, you would not be able to dynamically alter the C code on the fly from a Basic Script.  You could always set variables as options to modify its behavior on the fly.

Would this option work for you?

Regards
TK  


Group: DynoMotion Message: 8950 From: Tapio Larikka Date: 1/24/2014
Subject: Re: MyCustom.c on thread 5?

Hi Tom,
 
After looking around for a while I found the "SimpleCoffLoad" in examples. I modified the code to
...
(KM->CompileAndLoadCoff("..\\..\\C Programs\\MyCustom5.c",5))  ...
 
When I doubleclick the SimpleCoffLoad in KMotion examples a MyCustom5.out appears in my c-programs folder so I must have gotten
something right.
 
I proceeded with following in Mach button script.
 
        Dim CmdString As String
        Const AppFQFN = "C:\KMotion431d\KMotion\Release\SimpleCoffload.exe"
        CmdString = """" & APPFQFN & """" & " " & """" & 5 & """"
        Shell(CmdString)
 
Now the SimpleCoffLoad opens as with doubleclick but no MyCustom5.out appears in c program folder.
 
Can you think of the reason?
 
Rgds,
Tapio
 
 
----- Original Message -----
Sent: Friday, January 24, 2014 2:29 AM
Subject: Re: [DynoMotion] MyCustom.c on thread 5?

 

Hi Tapio,

ok now I understand the issue better.

Yes one request to execute Notify.c will block a subsequent request to execute Notify.c for something else (the requests are actually queued by our Plugin).  It will not necessarily block GCode from executing. 

So for example the Load Workpiece Sequence could be launched and G code could continue milling concurrently unless the Gcode came to a point where it need to do another Notify.c operation (like a tool change).  Then there would be a problem.  But Spindle commands, IO Bits, or DRO uploads/downloads would not be a problem.

The other solution for true concurrent operation would be similar to what you mentioned of using the Init.c program and a forever loop.  It could monitor a virtual I/O bit or Variable as a "go" command.  But then instead of launcing a new Thread as you proposed it could just perform the sequence.  Since the Init program is only compiled/downloaded/executed every time Mach3 RESET is pushed, you would not be able to dynamically alter the C code on the fly from a Basic Script.  You could always set variables as options to modify its behavior on the fly.

Would this option work for you?

Regards
TK  


Group: DynoMotion Message: 8953 From: Tom Kerekes Date: 1/24/2014
Subject: Re: MyCustom.c on thread 5?
Hi Tapio,

Try changing SimpleCoffLoad reference your C program with an absolute path as the current directory is likely to be a Mach3 directory.  

    if (KM->CompileAndLoadCoff("C:\\KMotion431d\\C Programs\\MyCustom5.c",5))    MyError();

Also don't forget to change which thread to execute to 5

    if (KM->WriteLine( "Execute5")) MyError();

Then in Mach3 CB Script do:

        X = Shell("C:\KMotion431d\KMotion\Release\SimpleCoffload.exe", 7)

(the 7 sets the window to be minimized to avoid an annoying screen flash)

Regards
TK



Group: DynoMotion Message: 8973 From: Tapio Larikka Date: 1/25/2014
Subject: Re: MyCustom.c on thread 5?

Hi Tom!
 
It looks like I got this working. I don't my Kflop so  it's not 100%, but now pressing Mach screen button produces a "MyCustom5(5).OUT" file.
 
Thank you for your help,
Tapio
 
----- Original Message -----
Sent: Saturday, January 25, 2014 7:40 AM
Subject: Re: [DynoMotion] MyCustom.c on thread 5?

 

Hi Tapio,

Try changing SimpleCoffLoad reference your C program with an absolute path as the current directory is likely to be a Mach3 directory.  

    if (KM->CompileAndLoadCoff("C:\\KMotion431d\\C Programs\\MyCustom5.c",5))    MyError();

Also don't forget to change which thread to execute to 5

    if (KM->WriteLine( "Execute5")) MyError();

Then in Mach3 CB Script do:

        X = Shell("C:\KMotion431d\KMotion\Release\SimpleCoffload.exe", 7)

(the 7 sets the window to be minimized to avoid an annoying screen flash)

Regards
TK